import { local } from "@/utils/local";
// store持久化
const storeRender = (store: any, stateName: string) => {
  store.state[stateName] = local.get(stateName);

  store.subscribe((mutation: any, state: any) => {
    local.set(stateName, state[stateName]);
    if (!state[stateName]) local.remove(stateName);
  });
};

export default (store: any) => {
  storeRender(store, "tokenObj");
  storeRender(store, "userInfo");
};
